
<html>
<head>
<meta charset="UTF-8">
<title>数据表模型字段列表</title>
<link href="../../static/easyui/themes/bootstrap/easyui.css" rel="stylesheet" type="text/css"/>
<link href="../../static/easyui/themes/icon.css" rel="stylesheet" type="text/css"/>
<script src="../../static/easyui/jquery.min.js" type="text/javascript"></script>
<script src="../../static/easyui/jquery.easyui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../../static/easyui/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.util.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.jquery.ajax.js" type="text/javascript"></script>
<script src="../../static/plugin/assets/jslib.easyui.util.js" type="text/javascript"></script>
<script src="../../ffres/dict/all.js"></script>
<a href="" target="_blank" id="commonLink" name="commonLink"></a>
<style type="text/css">
	.tbHr{float:left;min-width:800px;margin-left:-5px;width:80%;border: 1px solid #afafaf;}
</style>
</head>
<script type="text/javascript">

	$(function() {
		var objectName=decodeURI($.getUrlParam('objectName')) || '';
		document.getElementById("title").innerHTML=objectName+"-领域变量表格";
	});

	function doAdd(){
		JLEUtil.createModalWin('新增字段', 'ModelTableFieldAddNew.html?objectId=' + $.getUrlParam('objectId'));
	}
	
	function doUpdate() {
		var row = $('#dg').datagrid('getSelected');
		if (row){
			JLEUtil.createModalWin('修改字段', 'ModelTableFieldUpdateNew.html?' + 'fieldId=' + row.fieldId + '&itemId=' + row.itemId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doDelete(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.messager.confirm('删除提示', '你确定要删除这条记录?', function(r){
				if (r){
					var jsonData = JSON.parse('{'+'"fieldId":"' + row.fieldId + '"'+'}');
					$.restfulDelete('../../api/model/table/field', jsonData, function(data) {
						$.messager.alert('提示','记录删除成功!','info');
						$('#dg').datagrid('reload');
					});
				}
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}

	function doView(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('详情','ModelTableFieldViewNew.html?' + 'fieldId=' + row.fieldId + '&itemId=' + row.itemId);
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doSortUp(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.restfulGet('../../api/model/table/field/up/' + row.fieldId,null,function(data){
				$('#dg').datagrid('reload');
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doSortDown(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			$.restfulGet('../../api/model/table/field/down/' + row.fieldId,null,function(data){
				$('#dg').datagrid('reload');
			});
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doTableModelScript(){
		JLEUtil.createModalWin('建表语句', 'TableModelScript.html?objectId=' + $.getUrlParam('objectId'));
	}
	
	function doFieldOptionScript(){
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			if (row.fieldOption) {
				JLEUtil.createModalWin('字典插入语句', 'TableFieldOptionScript.html?fieldId=' + row.fieldId);
			} else {
				$.messager.alert('提示','该字段未配置字典信息','info');
			}
		} else {
			$.messager.alert('提示','请选择一条记录！','info');
		}
	}
	
	function doBatchImport(){
		JLEUtil.createModalWin('字段批量导入', 'FieldBatchImportStep1.html?objectId=' + $.getUrlParam('objectId'));
	}

	function doIndexMange(){
		var objectName = decodeURI($.getUrlParam('objectName')) || ''; 
		window.parent.addTab(objectName + '索引管理', 'ModelTableIndexList.html?objectId=' + $.getUrlParam('objectId'));
	}

	function doRefList() {
		var row = $('#dg').datagrid('getSelected');
		if (row) {
			JLEUtil.createModalWin('查看条目关联关系','DictItemInfoView.html?' + 'itemId=' + row.itemId);
		} else {
			$.messager.alert('提示','请选择数据条目！');
		}
	}

	function reloadList(){
		$('#dg').datagrid('reload');
		JLEUtil.closewin();
	};	

	function isPkFormatter(value,row,index) {
		if (value == "Y") {
			return formatter_STD_PUB_YN(value, row, index);
		} else {
			return "";
		}
	}

	function isAllowNullFormatter(value,row,index) {
		if (value == "N") {
			return formatter_STD_PUB_YN(value, row, index);
		} else {
			return "";
		}
	}
</script>
</head>
<body class="easyui-layout">
<div data-options="region:'north',title:''" class="divSearchBar" toolbar="#tb">
	<div id="tb" style="padding:1px;overflow: hidden">
		<div style="margin: 5px;">
			<a href="javascript:doAdd()" class="easyui-linkbutton" iconCls="icon-add" plain="true">创建字段</a>
			<a href="javascript:doUpdate()" class="easyui-linkbutton" iconCls="icon-edit" plain="true">编辑字段</a>
			<a href="javascript:doDelete()" class="easyui-linkbutton" iconCls="icon-remove" plain="true">删除字段</a>
			<a href="javascript:doView()" class="easyui-linkbutton" iconCls="icon-ok" plain="true">查看字段</a>
			<a href="javascript:doSortUp()" class="easyui-linkbutton" iconCls="icon-more" plain="true">顺序上升</a>
			<a href="javascript:doSortDown()" class="easyui-linkbutton" iconCls="icon-more" plain="true">顺序下降</a>
			<a href="javascript:doBatchImport()" class="easyui-linkbutton" iconCls="icon-man" plain="true">字段批量导入</a>
			<a href="javascript:doRefList()" class="easyui-linkbutton" iconCls="icon-man" plain="true">条目关联关系</a>
			<a href="javascript:doIndexMange()" class="easyui-linkbutton" iconCls="icon-man" plain="true">索引管理</a>
			<a href="javascript:doTableModelScript()" class="easyui-linkbutton" iconCls="icon-man" plain="true">建表语句</a>
			<a href="javascript:doFieldOptionScript()" class="easyui-linkbutton" iconCls="icon-man" plain="true">字典插入语句</a>
		</div>
	</div>
</div>
<div data-options="region:'center',split:false">
	<div id="div-thumbnail" style="position:absolute;width:100%;height:100%;margin-top:20px;margin-left:10%;overflow: hidden;">
		<table id="dg-thumbnail" class="tb" style="position:absolute;width:80%;margin-right: 10%;border: 1px solid #f4f4f4;">
			<tr>
				<div id="title" style="font-size: 14px;"></div>
				<hr class="tbHr">
			</tr>
			<tr>
				<form id="searchForm">
					<table style="background-color: #f4f4f4;height:30px;line-height:30px;min-width:800px;width: 80%;border-left: 1px solid #d4d4d4;border-right: 1px solid #d4d4d4;border-top: 1px solid #d4d4d4;">
						<tr>
							<td style="float:left;">&nbsp;字段代码：</td>
							<td style="float:left;margin-top: 5px"><input name="fieldCode" id="fieldCode"/></td>
							<td style="float:left;">&nbsp;字段名称：</td>
							<td style="float:left;margin-top: 5px"><input name="fieldName" id="fieldName"/></td>
							<td style="float:left;margin-top:3px"><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.queryForm('searchForm','dg','../../api/model/table/fields?objectId=' + $.getUrlParam('objectId'));">查找</a></td>
							<td style="float:left;margin-top:3px"><a class="easyui-linkbutton" href="javascript:void(0);" onclick="JLEUtil.clearForm('searchForm');">清空</a></td>
						</tr>
					</table>
				</form>
				<table id="dg" class="easyui-datagrid" title="" style="min-width:800px;width:80%;height:80%;"
						   data-options="singleSelect:true,collapsible:true,url:'../../api/model/table/fields?objectId=' + $.getUrlParam('objectId'),method:'post'"
						   title="Load Data" rownumbers="true" pagination="true" pageSize="20">
						<thead>
						<tr>
							<th data-options="field:'fieldCode',resizable:true" width="15%">字段代码</th>
							<th data-options="field:'fieldName',resizable:true" width="15%">字段名称</th>
							<th data-options="field:'fieldOrder',resizable:true" hidden="true">字段排序</th>
							<th data-options="field:'fieldType',resizable:true">字段类型</th>
							<th data-options="field:'fieldLength',resizable:true" width="8%" align="center">字段长度</th>
							<th data-options="field:'fieldPrecision',resizable:true" width="8%" align="center">字段精度</th>
							<th data-options="field:'fieldOption',resizable:true" width="13%" align="center">字段选项</th>
							<th data-options="field:'isPk',resizable:true" formatter="isPkFormatter" width="5%" align="center">主键</th>
							<th data-options="field:'isAllowNull',resizable:true" formatter="isAllowNullFormatter" width="5%" align="center">允空</th>
							<th data-options="field:'defValue',resizable:true" hidden="true">默认值</th>
							<th data-options="field:'fieldDesc',resizable:true" width="20%">字段描述</th>

						</tr>
						</thead>
					</table>
			</tr>
		</table>
	</div>
</div>
</body>
</html>

